﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace DataTier
{
    [KnownType(typeof(BatteryModel))]
    [DataContract(IsReference = true)]
    public class Battery
    {
        private BatteryModel _batteryModel;
        private int _batteryId; 
        private int _percentCharged;
        private DateTime _activeFrom;
        private int _timesCharged;

        #region Constructors

        public Battery(int batteryId, BatteryModel batteryModel, int percentCharged, DateTime activeFrom, int timesCharged)
        {
            this._batteryId = batteryId;
            this._batteryModel = batteryModel;
            this._percentCharged = percentCharged;
            this._activeFrom = activeFrom;
            this._timesCharged = timesCharged;
        }
        public Battery(int batteryId, int percentCharged, DateTime activeFrom, int timesCharged)
        {
            this._batteryId = batteryId;
            this._percentCharged = percentCharged;
            this._activeFrom = activeFrom;
            this._timesCharged = timesCharged;
        }

        public Battery(int batteryId, int percentCharged, int timesCharged)
        {
            this._batteryId = batteryId;
            this._percentCharged = percentCharged;
            this._timesCharged = timesCharged;
        }

        public Battery(int batteryId, int batteryModel, int percentCharged,  int timesCharged)
        {
            this._batteryId = batteryId;
            BatteryModel b = new BatteryModel(batteryModel);
            this._batteryModel = b;
            this._percentCharged = percentCharged;
            //this._activeFrom = activeFrom;
            this._timesCharged = timesCharged;
        }

        public Battery(int batteryId)
        {
            this._batteryId = batteryId;
        }

        public Battery(int batteryId, int lockedTo)
        {
            this._batteryId = batteryId;
        }

        #endregion

        #region Properties

        [DataMember]
        public int BatteryId
        {
            get { return _batteryId; }
            set { _batteryId = value; }
        }

        [DataMember]
        public BatteryModel BatteryModel
        {
            get { return _batteryModel; }
            set { _batteryModel = value; }
        }

        [DataMember]
        public int PercentCharged
        {
            get { return _percentCharged; }
            set { _percentCharged = value; }
        }

        [DataMember]
        public DateTime ActiveFrom
        {
            get { return _activeFrom; }
            set { _activeFrom = value; }
        }

        [DataMember]
        public int TimesCharged
        {
            get { return _timesCharged; }
            set { _timesCharged = value; }
        }


        #endregion
        public override string ToString()
        {
            return _batteryId.ToString();
        }
    }
}
